/**
 * Created by jinxs on 2015.08.28.
 */
/**
 * @summary 提供浏览器检测的模块
 * @name uiCore#browser
 * @function
 * @returns {string} 浏览器模块
 */
function webUI_browser() {
    var agent = navigator.userAgent.toLowerCase(),
        opera = window.opera,
        browser = {
            ie: /(msie\s|trident.*rv:)([\w.]+)/.test(agent),
            opera: (!!opera && opera.version),
            webkit: (agent.indexOf(' applewebkit/') > -1),
            firefox: (agent.indexOf('firefox') > -1),
            mac: (agent.indexOf('macintosh') > -1),
            quirks: (document.compatMode == 'BackCompat')
        };
    browser.gecko = (navigator.product == 'Gecko' && !browser.webkit && !browser.opera && !browser.ie);
    var version = 0;
    // Internet Explorer 6.0+
    if (browser.ie) {
        version = (agent.match(/(msie\s|trident.*rv:)([\w.]+)/)[2] || 0) * 1;
        browser.ie11Compat = document.documentMode == 11;
        browser.ie9Compat = document.documentMode == 9;
        browser.ie8 = !!document.documentMode;
        browser.ie8Compat = document.documentMode == 8;
        browser.ie7Compat = ((version == 7 && !document.documentMode)
        || document.documentMode == 7);
        browser.ie6Compat = (version < 7 || browser.quirks);
        browser.ie9above = version > 8;
        browser.ie9below = version < 9;
    }
    // Gecko.
    if (browser.gecko) {
        var geckoRelease = agent.match(/rv:([\d\.]+)/);
        if (geckoRelease) {
            geckoRelease = geckoRelease[1].split('.');
            version = geckoRelease[0] * 10000 + (geckoRelease[1] || 0) * 100 + (geckoRelease[2] || 0) * 1;
        }
    }
    if (/chrome\/(\d+\.\d)/i.test(agent)) {
        browser.chrome = +RegExp['\x241'];
    }
    if (/(\d+\.\d)?(?:\.\d)?\s+safari\/?(\d+\.\d+)?/i.test(agent) && !/chrome/i.test(agent)) {
        browser.safari = +(RegExp['\x241'] || RegExp['\x242']);
    }
    // Opera 9.50+
    if (browser.opera)
        version = parseFloat(opera.version());
    // WebKit 522+ (Safari 3+)
    if (browser.webkit)
        version = parseFloat(agent.match(/ applewebkit\/(\d+)/)[1]);
    browser.version = version;
    return browser;
}
